package com.example.juc;

import java.util.concurrent.atomic.AtomicReferenceArray;

public class AtomicReferenceArrayTest {
    public static void main(String[] args) {
        String datas[] = new String[]{"Jun", "De", "Yang"};
        AtomicReferenceArray<String> array = new AtomicReferenceArray<>(datas);
        System.out.println("【原子数据修改】数据修改的结果: " + array.compareAndSet(2, "Yang", "Yang2"));
        System.out.println("【原子数据获取】数组内容: ");
        for (int i = 0; i < array.length(); i++) {
            System.out.println(array.get(i) + "、" );
        }
    }
}
